import request from "@/utils/request";

//#region 计算机管理
// cn下的计算机列表 分页
export const pageList = query => {
  return request({
    url: "/ad/computer/pageList",
    method: "get",
    params: query
  });
};

//计算机信息
export const info = sAMAcountName => {
  return request({
    url: `/ad/computer/${sAMAcountName}/info`,
    method: "get"
  });
};

// cn下的个人计算机列表 分页
export const personalPageList = query => {
  console.log(query);
  return request({
    url: "/ad/computer/personalPageList",
    method: "get",
    params: query
  });
};

// cn下的公共计算机列表 分页
export const publicPageList = query => {
  return request({
    url: "/ad/computer/publicPageList",
    method: "get",
    params: query
  });
};

//生成计算机名
export const generateComputerName = samAccountName => {
  return request({
    url: "/ad/computer/generate",
    method: "get",
    params: { samAccountName }
  });
};

//创建私人计算机
export const createPersonComputer = samAccountName => {
  return request({
    url: "/ad/computer/createPersonalComputer",
    method: "post",
    params: { samAccountName }
  });
};

//创建公有计算机
export const createPublicComputer = (dn, computerName) => {
  return request({
    url: "/ad/computer/createPublicComputer",
    method: "post",
    params: { dn, computerName }
  });
};

//绑定私人计算机
export const bind = samAccountName => {
  return request({
    url: "/ad/computer/bindPersonalComputer",
    method: "post",
    params: { samAccountName }
  });
};

//解绑计算机
export const unbind = (samAccountName, computerType) => {
  return request({
    url: "/ad/computer/unbindComputer",
    method: "post",
    params: { samAccountName, computerType }
  });
};

//个人计算机管理 删除计算机
export const deleteComputer = samAccountName => {
  return request({
    url: `/ad/computer/${samAccountName}/delete`,
    method: "delete"
  });
};
// 导出
export const exportExcel = query => {
  return request({
    url: "/ad/computer/exportExcel",
    method: "post",
    params: query,
    responseType: "blob"
  });
};

export const createDefaultComputer = () => {
  return request({
    url: "/ad/computer/default",
    method: "post"
  });
};
////#endregion

export default {
  pageList,
  info,
  bind,
  unbind,
  deleteComputer,
  personalPageList,
  publicPageList,
  generateComputerName,
  createPersonComputer,
  createPublicComputer,
  exportExcel,
  createDefaultComputer
};
